﻿using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Scripting;
using Microsoft.Scripting.Ast;
using Microsoft.Linq.Expressions;

namespace DlrBasic.Parser.Ast
{
    class Clear : Statement
    {
        DlrBasicExpression expression1;
        DlrBasicExpression expression2;

        public Clear(SourceSpan span, DlrBasicExpression expression1, DlrBasicExpression expression2)
            : base(span)
        {
            this.expression1 = expression1;
            this.expression2 = expression2;
        }

        protected internal override Expression Generate(DlrBasicGenerator generator, StateMemberGenerator stateParameter, LambdaBuilder builder)
        {
            Expression clearMemory = Expression.Call(
                stateParameter.GetMemoryVariable(),
                typeof(Runtime.DlrBasicMemory).GetMethod("Clear"));
            return Expression.Block(clearMemory,
                base.Generate(generator, stateParameter, builder));
        }
    }
}
